<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">
		<title>My JSP 'noticAll.jsp' starting page</title>
		<link rel="stylesheet" type="text/css"
			href="${pageContext.request.contextPath}/easyui/1.3.4/themes/default/easyui.css" />
		<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/wu.css" />
		<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/icon.css" />
		<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.8.0.min.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/easyui/1.3.4/jquery.easyui.min.js"></script>
		<script type="text/javascript"
			src="${pageContext.request.contextPath}/easyui/1.3.4/locale/easyui-lang-zh_CN.js"></script>
			<style type="text/css">
				a:link {color:blue;}/* 未被访问的链接 */
				a:visited {color:#00FF00;}/* 已被访问的链接 */
				a:hover {color:#FF00FF;}/* 鼠标指针移动到链接上 */
				a:active {color:#0000FF;}/* 正在被点击的链接 */
			</style>
		<script type="text/javascript">
		$(function(){
		$("#noticff").submit(function(){
			var tital=$("#titals").val();
			var content=$("#contents").val();
			var startshow=$("#startshows").datetimebox('getValue');
			var endshow=$("#endshows").datetimebox('getValue');
			if(tital==""||tital==null ){
				alert('标题不能为空');
				return false;
			}else if(tital.length>30){
				alert('不能超出最大范围');
				return false;
				}
			if(content==""||content==null){
				alert('内容不能为空');
				return false;
			}else if(content.length>50){
				alert('不能超出最大范围');
				return false;
				}
			if(startshow==""||startshow==null){
				alert('请填入开始时间');
				return false;
			}
			if(endshow==""||endshow==null){
				alert('请填入结束时间');
				return false;
			}
				return true;	
	});
	});

		$(function() {
				$("#tab").datagrid( {
					url : '${pageContext.request.contextPath}/notice?op=show2',
					columns : [ [ {
						field : 'id',
						title : '编号'
					}, {
						field : 'tital',
						title : '标题',
						width : 100,
						formatter: function(value,row,index){
											return '<a style="color:blue" href="${pageContext.request.contextPath}/notice?op=show3&id='+row.id+'">'+row.tital+'</a>';							
											}	
						
					}, {
						field : 'startshow',
						title : '日期',
						width : 100,
						formatter: function(value,row,index){
							return value.substring(0,10);
						}
						
					} ] ],
					fitColumns : true,
					autoRowHeight : false,
					striped : true,
					loadMsg : '请等待...',
					pagination : true,
					nowrap : true,
					rownumbers : true,
					fit : true,
					singleSelect:true,
					toolbar : [ {
						iconCls : 'icon-add',
						handler : function() {
							$("#win").window( {
								width : 600,
								height : 400,
								modal : true,
								title : '添加通告',
								iconCls : 'icon-add'
							});
						}
					} ,
					 '-', {
					 	text:'返回主页',
						iconCls : 'icon-undo',
						handler : function() {
							location.href='${pageContext.request.contextPath}/mydesk.jsp';
							//history.go(-1);
						}
					} ]
		
				});
			});
	$(function(){
		$("#search").click(function(){	
			var id = $("#id").val();
			$("#tab").datagrid( {
			url : 'notice?op=show4',
			queryParams: {
					id: id	
				},			
			columns : [ [ {
				field : 'id',
				title : '编号',
				checkbox : true
			}, {
				field : 'tital',
				title : '标题',
				width : 100},
				{
				field : 'startshow',
				title : '日期',
				width : 100,
				formatter: function(value,row,index){
							return value.substring(0,10);
						}
			} ] ],
			fitColumns : true,
			autoRowHeight : false,
			striped : true,
			loadMsg : '请等待...',
			pagination : true,
			nowrap : true,
			rownumbers : true,
			fit : true,
			singleSelect:true,
			toolbar : [ {
				iconCls : 'icon-edit',
				handler : function() {
				var obj = $("#tab").datagrid("getSelected");
					$("#update").window( {
						width : 600,
						height : 400,
						modal : true,
						title : '修改通告',
						iconCls : 'icon-edit'
					});
					$("#ff").form('load',{
						id:obj.id,
						tital:obj.tital,
						content:obj.content,
						startshow:obj.startshow.substring(0,10),
						endshow:obj.endshow.substring(0,10),
						noticelv:obj.noticelv,
						state:obj.state
					});

				}
			} ]

		});
		});		
	});
	
</script>
	</head>
	<body class="easyui-layout">
	
		<div data-options="region:'west',title:'通告管理',split:true"
			style="width: 200px;">
			<ul>
				<li style="list-style: none;">
					<h3>
						<a href="${pageContext.request.contextPath}/noticAll.jsp">查看通告</a>
					</h3>
				</li>
				<li style="list-style: none; margin-top: 15px">
					<h3>
						<a href="javascript:void(0);" id="search">查看草稿</a>
					</h3>
				</li>
				
			</ul>
			
		</div>

		<div data-options="region:'center'">
			<table id="tab">
				<input type="hidden" name="id" id="id" value="${sys_user.id}">
			</table>
			<div id="win">
				<form action="notice?op=show5" method="post" id="noticff">
					<input type="hidden" name="id" value="${sys_user.id}">
					<table>
						<tr>
							<td>
								标题:
							</td>
							<td>
								<input type="text" name="tital" id="titals">
							</td>
						</tr>
						<tr>
							<td>
								内容:
							</td>
							<td>
								<textarea rows="3px" cols="40px" name="content" id="contents"></textarea>
							</td>
						</tr>
						<tr>
							<td>
								start:
								<input class="easyui-datebox" name="startshow"
									style="width: 150px" id="startshows">
							</td>
							<td>
								end：
								<input class="easyui-datebox" name="endshow"
									style="width: 150px" id="endshows">
							</td>
						</tr>
						<tr>
							<td>
								类型:
							</td>
							<td>
								<select name="noticelv">
									<option value="1" selected="selected">
										紧急
									</option>
									<option value="0">
										一般
									</option>
								</select>
							</td>
						</tr>
						<tr>
							<td></td>
							<td>
								<label>
									<input name="state" type="radio" value="0" />
									草稿
								</label>
								<label>
									<input name="state" type="radio" value="1" />
									发布
								</label>
							</td>
						</tr>
						<tr>
							<td>
								<input type="submit" value="提交" />
							</td>

						</tr>
					</table>

				</form>
			</div>
			<div id="update">
				<form action="notice?op=update" method="post" id="ff">
					<input type="hidden" name="id" value="${sys_user.id}">
					<table>
						<tr>
							<td>
								标题:
							</td>
							<td>
								<input type="text" name="tital">
							</td>
						</tr>
						<tr>
							<td>
								内容:
							</td>
							<td>
								<textarea rows="3px" cols="40px" name="content"></textarea>
							</td>
						</tr>
						<tr>
							<td>
								start:
								<input class="easyui-datebox" name="startshow"
									style="width: 150px">
							</td>
							<td>
								end：
								<input class="easyui-datebox" name="endshow"
									style="width: 150px">
							</td>
						</tr>
						<tr>
							<td>
								类型:
							</td>
							<td>
								<select name="noticelv">
									<option value="1" selected="selected">
										紧急
									</option>
									<option value="0">
										一般
									</option>
								</select>
							</td>
						</tr>
						<tr>
							<td></td>
							<td>
								<label>
									<input name="state" type="radio" value="0" />
									草稿
								</label>
								<label>
									<input name="state" type="radio" value="1" />
									发布
								</label>
							</td>
						</tr>
						<tr>
							<td>
								<input type="submit" value="提交" />
							</td>

						</tr>
					</table>

				</form>
			</div>
		</div>
	</body>
</html>
